package mobileclouds.com.example;

import java.util.List;

import com.parse.FindCallback;
import com.parse.Parse;
import com.parse.ParseException;
import com.parse.ParseFile;
import com.parse.ParseObject;
import com.parse.ParseQuery;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class MainActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		Parse.initialize(this, "6nU5yimGzOb8kO2AWmFi7kjRL1RULLWIuyXx1Nhf", "hYiZ8moOmx0wjl6KRPoJ67zksMHg3C25Z4NRAzVd");

		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		Button download = (Button) findViewById(R.id.button1);
		download.setOnClickListener(new OnClickListener()
        {
        	public void onClick(View v)
        	{
        		ParseQuery pq = new ParseQuery("Lolcat");
        		pq.whereEqualTo("name", "asdf");
        		pq.findInBackground(new FindCallback() {
        		    public void done(List<ParseObject> scoreList, ParseException e) {
        		        if (e == null) {
        		        	LoaderImageView image = (LoaderImageView) findViewById(R.id.loaderImageView);
        		        	image.setVisibility(1);
        		        	String str = ((ParseFile)  scoreList.get(0).get("textfile")).getUrl().toString();
        		        	image.setImageDrawable(str);
        		        } else {
        		        }
        		    }
        		});
        	}
        });

	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_main, menu);
		return true;
	}

}
